// GuessNumberUserInterface.java
//
// ICS 22 / CSE 22 Winter 2010
// In-Lab Assignment #0
//
// This class implements the user interface for the "guess a number"
// game, where the computer chooses a number at random, then asks the
// user to guess what it is, giving hints along the way.

import java.util.Scanner;


public class GuessNumberUserInterface
{
	private static int RANGE = 100;

	
	public static void main(String[] args)
	{
		Scanner s = new Scanner(System.in);

		GuessNumberGame game = new GuessNumberGame(RANGE);

		System.out.println("I'm thinking of a number between 1 and 100.  Can you guess what it is?");
		
		GuessResponse response;
		
		int counter = 5;
		do
		{
			System.out.print("Enter a number between 1 and 100: ");
			
			int guess = s.nextInt();
			s.nextLine();
			
			response = game.checkGuess(guess);

			if (response == GuessResponse.TARGET_IS_SMALLER)
			{
				System.out.println("The number I'm thinking of is smaller than that.");
			}
			else if (response == GuessResponse.TARGET_IS_LARGER)
			{
				System.out.println("The number I'm thinking of is larger than that.");
			}
			counter--;
			System.out.println("counter= "+counter);
		}
		while (response != GuessResponse.CORRECT && counter > 0);
		if(response == GuessResponse.CORRECT)
			System.out.println("Great job!  That's exactly the number I was thinking of!");
		else
			System.out.println("Ran out of guesses. Answer is "+ game.getTargetNumber());
	}
}
